package com.ynet.hmds28.user.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.boot.hsf.annotation.HSFProvider;
import com.ynet.hm.user.domain.ServiceConsumeBean;
import com.ynet.hm.user.service.StatisticalBillService;
import com.ynet.hmds28.user.dao.ServiceconsumeDao;
import com.ynet.hmds28.user.model.Serviceconsume;
import com.ynet.hmds28.user.model.ServiceconsumeQuery;


@Transactional
@HSFProvider(serviceInterface = StatisticalBillService.class, serviceVersion = "1.0.0",serviceGroup = "hmds28")
public class StatisticalBillServiceImpl implements StatisticalBillService {

	@Autowired
	private ServiceconsumeDao serviceconsumeDao;
	
	@Override
	public ServiceConsumeBean statisticalBill(String serviceproviceId,
			String merchanNo) {
		//开启GTS事务
		serviceconsumeDao.enableTXC();
		ServiceConsumeBean scb = new ServiceConsumeBean();
		serviceconsumeDao.statisticalBill(serviceproviceId, merchanNo);
		ServiceconsumeQuery example = new ServiceconsumeQuery();
		example.createCriteria().andSeviceproviceidEqualTo(serviceproviceId).andUseridEqualTo(merchanNo);
		List<Serviceconsume> scList = serviceconsumeDao.selectByExample(example);
		scb.setCallcost(scList.get(0).getCallcost());
		scb.setCallnum(scList.get(0).getCallnum());
		return scb;
	}
	
	
}
